﻿using VirtualTournaments.DataAccess.SqlServer.DataProxies;

namespace VirtualTournaments.DataAccess.SqlServer.DataMappers
{
	internal sealed class TournamentPodiumBetTypesDataMapper : AbstractDataMapper<SqlServer.BetType, Business.Bets.TournamentPodiumBetType, DataProxies.TournamentPodiumBetTypeDataProxy>
	{
		#region Singleton implementation

		private static TournamentPodiumBetTypesDataMapper _instance = null;
		private static object _instanceLocker = new object();

		private TournamentPodiumBetTypesDataMapper() { }

		public static TournamentPodiumBetTypesDataMapper Instance
		{
			get
			{
				if (_instance == null)
				{
					lock (_instanceLocker)
					{
						if (_instance == null)
						{
							_instance = new TournamentPodiumBetTypesDataMapper();
						}
					}
				}
				return _instance;
			}
		}

		#endregion

		internal override VirtualTournamentsDataContext GetDataContext()
		{
			return VirtualTournamentsDataContext.Instance;
		}

		internal override System.Data.Linq.Table<BetType> GetDataTable()
		{
			return GetDataContext().BetTypes;
		}

		internal override Business.Bets.TournamentPodiumBetType DataObject2BusinessObject(SqlServer.BetType dataObject)
		{
			Business.Tournaments.Tournament tournament = AllAgainstAllTournamentsDataMapper.Instance.GetOneAsBusinessObject(_tournament => _tournament.TournamentId == dataObject.TournamentId);
			return new TournamentPodiumBetTypeDataProxy(dataObject, tournament);
		}

		internal override void BusinessObject2DataObject(Business.Bets.TournamentPodiumBetType businessObject, SqlServer.BetType dataObject)
		{
			throw new System.NotImplementedException();
		}

		internal override void DataProxy2DataObject(TournamentPodiumBetTypeDataProxy dataProxy, SqlServer.BetType dataObject)
		{
			throw new System.NotImplementedException();
		}
	}
}
